import java.util.*;

public class testwork1 {
    public static int singleNumber(int[] nums) {
        HashSet<Integer> set=new HashSet<>();
        for (int i = 0; i <nums.length ; i++) {
            if(set.contains(nums[i])){
                set.remove(nums[i]);
            }
            else {
                set.add(nums[i]);
            }
        }
        int i=0;
        Iterator<Integer> iterator = set.iterator();
        while ( iterator.hasNext()) {
            i = iterator.next();
        }
        return i;
    }
    public static void main(String[] args) {
        Map<Integer,Integer>map=new HashMap<>();
        int []arr={1,5,1,5,2};
        System.out.println(singleNumber(arr));
    }
}
